﻿@page "/Users"
@using Microsoft.AspNetCore.Authorization

@attribute [Authorize]

<PageTitle>Benutzer</PageTitle>

<MudStack Row="true" Class="mb-8">
    <MudText Typo="Typo.h4">Benutzer</MudText>
    <MudSpacer />
    <MudIconButton Icon="@Icons.Material.Filled.Add" Color="Color.Primary" Href="/Users/Add" />
</MudStack>

@if (users == null)
{
    <p><em>Lade...</em></p>
}
else
{
    <MudDataGrid Items="@users" SortMode="SortMode.Single" Class="mb-8">
        <Columns>
            <PropertyColumn Property="x => x.Email" Title="E-Mail" />
            <PropertyColumn Property="x => x.Firstname" Title="Vorname" />
            <PropertyColumn Property="x => x.Lastname" Title="Nachname" />
            <TemplateColumn CellClass="d-flex justify-end">
                <CellTemplate>
                    <MudIconButton Icon="@Icons.Material.Outlined.FindInPage" Href="@($"/Users/{context.Item.Id}")" Size="@Size.Small" Color="@Color.Primary"></MudIconButton>
                    <MudIconButton Icon="@Icons.Material.Outlined.Edit" Href="@($"/Users/{context.Item.Id}/Edit")" Size="@Size.Small" Color="@Color.Primary"></MudIconButton>
                </CellTemplate>
            </TemplateColumn>
        </Columns>
    </MudDataGrid>
}